|
|
|
|
|
|
|
To demonstrate, add the following code to the user control's InitProperties event: |
|
|
|
|
|
|
|
|
UserControl.Extender.ToolTipText = "Testing the Extender object" |
|
|
|
|
|
|
|
|
Next, draw an instance of the control on the form. The ToolTipText property should automatically appear after the control instance is drawn. You can verify this fact by hovering the mouse pointer over the control, as shown in Figure 15.3. |
|
|
|
|
|
|
|
|
Figure 15.3
The Extender object allows the control
to change properties set by its container. |
|
|
|
|
|
|
|
|
Building the Calculator Control |
|
|
|
|
|
|
|
|
In this section, you build a sample Calculator control to be used as the basis for the topics presented in the remainder of this chapter. The Calculator control is a simple ActiveX control that allows users to provide two input values and perform a mathematical operation on them: multiply, add, subtract, or divide. The mathematical operation is controlled by the Operation property and performed when the users click a button. The sample control is shown in Figure 15.4. |
|
|
|
|
|
|
|
|
Figure 15.4
This Calculator control has its
constituent controls in place. |
|
|
|
|
|
|
|
|
To create the Calculator control, start a new ActiveX Control project. Then arrange the following constituent controls on the new UserControl designer: |
|
|
|
|
|
|
|
|
lblCaptionA label that the users will access through the Caption property of the control. |
|
|
|
|
|
|
|
|
txtNum1 and txtNum2Text boxes that hold input from the users. |
|
|
|
|
|
|
|
|
lblOperationA label between the text boxes indicating which operation is to be performed. |
|
|
|
|
|
|
|
|
lblEqualsA label that displays the equal sign (=) to indicate a mathematical equation visually. |
|
|
|
|
|